package scope

import (
	"gitee.com/mkwchecking/sr-core/domain/dao/quick_search"
	"gorm.io/gorm"
)

type Scope func(*gorm.DB) *gorm.DB

type IScope interface {
	MakeScope() Scope
}

func newFuncScope(fb Scope) IScope {
	return funcScope{
		fb: fb,
	}
}

type funcScope struct {
	fb Scope
}

func (f funcScope) MakeScope() Scope {
	return f.fb
}

func Search(obj any) Scope {
	if obj == nil {
		return nil
	}
	return quick_search.Search(obj)
}
